package com.zit.presentation.action;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ApplicationAware;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.zit.util.MD5;
import com.zit.util.PageUtil;
import com.zit.util.SystemUtil;

public abstract class BaseAction extends ActionSupport implements RequestAware , SessionAware , ApplicationAware , ServletRequestAware , ServletResponseAware {

	protected static final String MAIN = "main";
	
	protected int currentUserId ;
	
	protected Map<String,Object> requestMap ;
	protected Map<String,Object> sessionMap ;
	protected Map<String,Object> applicationMap ;
	
	public void setRequest(Map<String, Object> requestMap) {
		this.requestMap = requestMap ;
	}

	public void setSession(Map<String, Object> sessionMap) {
		this.sessionMap = sessionMap ;
	}

	public void setApplication(Map<String, Object> applicationMap) {
		this.applicationMap = applicationMap ;
	}

	
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	
	public void setServletRequest(HttpServletRequest request) {
		this.request = request ;
	}

	public void setServletResponse(HttpServletResponse response) {
		this.response = response ;
	}
	
	protected PageUtil pageUtil ;

	public PageUtil getPageUtil() {
		return pageUtil;
	}

	public void setPageUtil(PageUtil pageUtil) {
		this.pageUtil = pageUtil;
	}

	protected String md5(String str){
		return MD5.md5(str);
	}
	
	public String getContentPath(String child){
		return ServletActionContext.getServletContext().getRealPath("/"+child);
	}
	
	public int getCurrentUserId() {
		return currentUserId;
	}

	public void setCurrentUserId(int currentUserId) {
		this.currentUserId = currentUserId;
	}
	
	public Date getNow(){
		return new Date();
	}
}
